var getAbsoluteCoords = function (e) {
	var width = e.offsetWidth;
	var height = e.offsetHeight;
	var left = e.offsetLeft;
	var top = e.offsetTop;
	while (e=e.offsetParent) {
		left += e.offsetLeft;
		top+= e.offsetTop;
	};
	var right = left+width;
	var bottom = top+height;
	return {
		'width': width,
		'height': height,
		'left': left,
		'top': top,
		'right': right,
		'bottom': bottom
	};
};

/* Kernel code, drag div change the coords */
/* by never-online, http://www.never-online.net */

var wrapId = "tree";
var wrap = document.getElementById(wrapId); 
wrap.onmouseover = function () {
	wrap.style.cursor = "se-resize";
	document.onmousedown = function (evt) {
		evt = window.event||evt; var a=getAbsoluteCoords(wrap);
		wrap.cx=evt.clientX-a.width; wrap.cy=evt.clientY-a.height
		document.onmousemove = function (evt) {
			evt = window.event||evt; 
			wrap.style.width = (evt.clientX-wrap.cx)+"px";
			wrap.style.height = (evt.clientY-wrap.cy)+"px";
		};
		document.onmouseup = function () {
			document.onmousemove = null;
			document.onmouseup = null;
			wrap.style.cursor="default";
		};
	};
}
